import { Get, Post, Put, Delete } from '../server/http';
import { basePost as basePostForm } from '../server/http_form';
import { URL } from '../server/enum';

// 封装通用请求方法，可与接口地址拼接
export const BASE_URL = 'http://10.102.13.55:5000';
// export const BASE_URL = 'http://172.16.2.158:18001';


export const generalRequest = (method, path) => {
  const url = `${BASE_URL}${path}`;
  switch (method.toUpperCase()) {
    case 'GET':
      return Get(url);
    case 'POST':
      return Post(url);
    case 'PUT':
      return Put(url);
    case 'DELETE':
      return Delete(url);
    default:
      throw new Error(`不支持的请求方法: ${method}`);
  }
};


// 获取老年人补贴信息
export const getElderlySubsidy = () => {
  return generalRequest('GET', '/elderly/elderly-subsidy');
};

// 补贴相关接口
export const SUBSIDY_API = {
  // 高龄补贴相关的接口
  ELDERLY: {
    LIST: `${BASE_URL}/api/elderly/elderly-subsidy`,
    INFO: (id) => `${BASE_URL}/api/elderly/elderly-subsidy/${id}`,
  },
  // 生态补贴相关接口
  ECOLOGICAL: {
    LIST: `${BASE_URL}/api/ecological/ecological-subsidy`,
    INFO: (id) =>`${BASE_URL}/api/ecological/ecological-subsidy/${id}`,
  },
  // 暑假实习相关的补贴接口
  INTERNSHIP: {
    LIST: `${BASE_URL}/api/internship/internship-subsidy`,
    INFO: (id) =>`${BASE_URL}/api/internship/internship-subsidy/${id}`,
  },
  // 移民补贴的接口
  IMMIGRATION: {
    LIST: `${BASE_URL}/api/immigration/immigration-subsidy`,
    INFO: (id) =>`${BASE_URL}/api/immigration/immigration-subsidy/${id}`,
  },
  // 耕地补贴接口
  FARMLAND: {
    LIST: `${BASE_URL}/api/farmland/farmland-subsidy`,
    INFO: (id) =>`${BASE_URL}/api/farmland/farmland-subsidy/${id}`,
  },
  // 大学生就业补贴
  STUDENT: {
    LIST: `${BASE_URL}/api/student/student-subsidy`,
    INFO: (id) =>`${BASE_URL}/api/student/student-subsidy/${id}`,
  },
  // 可以添加其他类型的补贴接口
  EMPLOYMENT: {
    LIST: `${BASE_URL}/api/employment/employment-subsidy`,
    INFO: (id) =>`${BASE_URL}/api/employment/employment-subsidy/${id}`,
  },
  // 可以添加其他类型的补贴接口
  FLEX_EMPLOYMENT: {
    LIST: `${BASE_URL}/api/flex_employment/flex-employment-subsidy`,
    INFO: (id) =>`${BASE_URL}/api/flex_employment/flex-employment-subsidy/${id}`,
  },
};

// 违规补贴相关接口
export const DOUBT_API = {
  //高龄违规
  ELDERLY: {
    LIST: `${BASE_URL}/api/elderly/illegal-elderly-subsidy`,
    UPDATE: (id) => `${BASE_URL}/api/elderly/illegal-elderly-subsidy/${id}`,
  },
  // 违规生态效益补偿兑换接口
  ECOLOGICAL: {
    LIST: `${BASE_URL}/api/ecological/illegal-ecological-subsidy`,
    UPDATE:(id) => `${BASE_URL}/api/ecological/illegal-ecological-subsidy/${id}`,
  },
    // 违规暑假实习实践
  INTERNSHIP: {
    LIST: `${BASE_URL}/api/internship/illegal-internship-subsidy`,
    UPDATE:(id) => `${BASE_URL}/api/internship/illegal-internship-subsidy/${id}`,
  },
  // 违规移民数据的接口
  IMMIGRATION: {
    LIST: `${BASE_URL}/api/immigration/illegal-immigration-subsidy`,
    UPDATE:(id) => `${BASE_URL}/api/immigration/illegal-immigration-subsidy/${id}`,
  },
    // 违规耕地补贴接口
  FARMLAND: {
    LIST: `${BASE_URL}/api/farmland/illegal-farmland-subsidy`,
    UPDATE: (id) =>`${BASE_URL}/api/farmland/illegal-farmland-subsidy/${id}`,
  },
    // 违规大学生就业补贴接口
  STUDENT: {
    LIST: `${BASE_URL}/api/illegal-student-subsidy`,
    UPDATE: (id) =>`${BASE_URL}/api/illegal-student-subsidy/${id}`,
  },
    // 违规一次性就业、创业补贴接口
  EMPLOYMENT: {
    LIST: `${BASE_URL}/api/employment/illegal-employment-subsidy`,
    UPDATE: (id) =>`${BASE_URL}/api/employment/illegal-employment-subsidy/${id}`,
  },
  // 违规灵活就业和一次性就业补贴接口
  FLEX_EMPLOYMENT: {
    LIST: `${BASE_URL}/api/flex_employment/illegal-flex-employment-subsidy`,
    UPDATE: (id) =>`${BASE_URL}/api/flex_employment/illegal-flex-employment-subsidy/${id}`,
  },
};
